package request;

import com.example.demo09Tomcat.HelloServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

/*
 3: 获取请求头数据
         请求体: 只有post请求方式才有请求体,在请求体中封装了post请求的请求参数
         * 步骤:
             1:获取流对象
               * BufferedReader getReader(): 获取字符输入流,只能操作字符数据
               * ServletInputStream getInputStream():获取字节输入流,可以操作所有类型数据
             2:再从流对象中拿数据
*/

@WebServlet("/demo04")
public class Servletdemo03 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求消息
         //获取字符流
        BufferedReader aa = req.getReader();
         //读取数据
        //这里的数据从register.html中获取
        String line;
        while((line=aa.readLine())!=null){
            System.out.println(line);
        }
    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

    }
}
